//--------------------------------------- NOTES ------------------------------------------------------//
* This table is Table A1 in the paper 
//--------------------------------------------------------------------------------------------------------//

cd  "/YOUR_LOCAL_DIRECTORY" //setting the working directory
clear all //remove all data, labels, matrices etc (incl. Mata functions)
use August17ChanRoth.dta, clear

** drop player who participated mulitple times
drop if room=="HRSUs" | room=="FQkZh"

* Create the key treatment variable
gen byte status_quo = treatment=="status_quo"
la var status_quo  "Status Quo"

* Create Y variable
gen deaths =.
gen mortalitylow = 1 if drawn_low=="red"
replace mortalitylow=0 if drawn_low=="blue"
gen mortalityhigh = 1 if drawn_high=="red"
replace mortalityhigh=0 if drawn_high=="blue"
replace deaths= mortalitylow+ mortalityhigh
gen mortality = deaths/2

* Make table

eststo clear

eststo: quietly reg mortality status_quo,  vce(cluster room) // Compare mortality rate by treatment group
eststo: quietly reg mortality status_quo player1bluecount player2highbluecount player2lowbluecount,  vce(cluster room) // Compare mortality rate by treatment group
*eststo: quietly reg mortality status_quo player1bluecount player2highbluecount player2lowbluecount i.round,  vce(cluster room) // Compare mortality rate by treatment group

eststo: quietly reg mortalitylow status_quo,  vce(cluster room) // Compare mortality rate by treatment group
eststo: quietly reg mortalitylow status_quo player1bluecount player2highbluecount player2lowbluecount,  vce(cluster room) // Compare mortality rate by treatment group
*eststo: quietly reg mortalitylow status_quo player1bluecount player2highbluecount player2lowbluecount i.round,  vce(cluster room) // Compare mortality rate by treatment group

eststo: quietly reg mortalityhigh status_quo,  vce(cluster room) // Compare mortality rate by treatment group
eststo: quietly reg mortalityhigh status_quo player1bluecount player2highbluecount player2lowbluecount,  vce(cluster room) // Compare mortality rate by treatment group
*eststo: quietly reg mortalityhigh status_quo player1bluecount player2highbluecount player2lowbluecount i.round,  vce(cluster room) // Compare mortality rate by treatment group

esttab using table_mortality_0a1.tex, se r2  keep(status_quo player1bluecount player2highbluecount player2lowbluecount _cons) star(+ 0.1 * 0.05 ** 0.01)

label variable player1bluecount "Jar \# Blue Balls"
label variable player2highbluecount "High Urn \# Blue Balls"
label variable player2lowbluecount "Low Urn \# Blue Balls"


local numbers "& (1) & (2) & (3) & (4) & (5) & (6) \\ \hline"

esttab using table_mortality_a1.tex, se r2  keep(status_quo player1bluecount player2highbluecount player2lowbluecount _cons) star(+ 0.1 * 0.05 ** 0.01) b(3)  mgroups("\% Red Balls for all Urns" "\% Red Balls for Low Blue Urns" "\% Red Balls for High Blue Urns", pattern(1 0 1 0 1) prefix(\multicolumn{2}{c}{) suffix(}) span) mlabels(none) nonumbers posthead("`numbers'") label title("Impact on Bad Outcomes (Red Balls Drawn)") substitute([htbp] [!htbp] \begin{tabular} \small\begin{tabular} {l} {p{\linewidth}}) addnotes("(Robust, clustered by player-pairings)") stat(N r2, label("N" "\[R^2\]") fmt(a3 %9.3fc))
